//
//  ClassifyCollectionViewCell.m
//  MyNewProject
//
//  Created by 王春辉 on 2019/12/21.
//  Copyright © 2019年 sun. All rights reserved.
//

#import "ClassifyCollectionViewCell.h"

@implementation ClassifyCollectionViewCell
@synthesize imageView = _imageView;
@synthesize titleLabel = _titleLabel;
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self setupContentViews];
    }
    return self;
}
- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        _imageView.layer.masksToBounds = true;
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
        _imageView.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:_imageView];
    }
    return _imageView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = SKColorWithHex(0x333333);
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = SKFONT_SIZE(13);
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.layer.cornerRadius = self.imageView.width * 0.5;
}
/**
 设置contentViews
 */
- (void)setupContentViews {
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.centerX.mas_offset(0);
        make.height.mas_equalTo(13);
        make.left.mas_lessThanOrEqualTo(0);
    }];
    
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.centerX.mas_offset(0);
        make.bottom.mas_equalTo(self.titleLabel.mas_top).mas_offset(-10);
        make.width.mas_equalTo(self.imageView.mas_height);
    }];
}
@end
